Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serve workflow templates from custom_nodes #6193

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

bezo97
Copy link

@bezo97 bezo97 commented Dec 23, 2024

This PR prepares the following feature request: Comfy-Org/ComfyUI_frontend#1008
Related frontend PR: Comfy-Org/ComfyUI_frontend#2032

Implementation details:

  • @routes.get("/workflow_templates") - This endpoint returns a map of custom_nodes names and their associated workflow template files. The ones without templates are omitted. Example:
{
    "ComfyUI-LTXTricks": [
        "example_ltxv_stg",
        "example_ltx_flow_edit",
        "example_ltx_interpolation",
        "example_ltx_inversion",
        "example_ltx_iv2v",
        "example_ltx_rf_edit"
    ],
    "ComfyUI_Noise": [
        "unsample_example",
        "variations_example"
    ]
}
  • LOADED_MODULE_DIRS where we keep track of all successfully loaded custom_nodes and their directories (even when there is no class mapping and web directory)
  • files are served from each custom_nodes's specific subfolder if exists, like this: custom_nodes/*/example_workflows/*

Question to reviewers:

  • Is serving from the /example_workflows folders sufficient or shall we support existing folder structures of popular custom_node repos by allowing /examples, /workflows, etc.?

server.py Outdated
@@ -250,6 +250,16 @@ async def get_extensions(request):
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))

return web.json_response(extensions)

@routes.get("/workflow_templates")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a plan to eventually move ComfyUI-Manager's custom node management features to core. Can we move this endpoint to a separate file app/custom_node_manager.py?

server.py Outdated

@routes.get("/workflow_templates")
async def get_workflow_templates(request):
files = glob.glob(os.path.join(folder_paths.custom_nodes_directory, '*/example_workflows/*.json'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just call folder_paths.get_folder_paths("custom_nodes") here instead of adding a new global variable in folder_paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants